package com.dao.impl;

import com.dao.ChartDao;
import com.dao.ChartRedisDao;
import com.dao.RefreshChartDao;
import com.entity.Chart;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.sql.SQLException;
import java.util.List;

@Component
public class RefreshChartDaoImpl implements RefreshChartDao {
    @Resource
    ChartDao chartDao;
    @Resource
    ChartRedisDao chartRedisDao;

    @Override
    public void refreshCountStudentChartByClazz() throws SQLException, ClassNotFoundException {
        List<Chart> chartsByCountStudentScore = chartDao.getCountStudentScoreChartByClazz();
        List<Chart> chartsByCountStudentNO = chartDao.getCountStudentNOChartByClazz();
        chartRedisDao.pushCharts(chartsByCountStudentScore, "clazzTop3byScore");
        chartRedisDao.pushCharts(chartsByCountStudentNO, "clazzTop3byNO");
    }
}
